"""
@Filename       : adj_svd.py
@Create Time    : 2021/11/16 21:16
@Author         : Rylynn
@Description    : 

"""
import numpy as np
import pickle as pkl
from  matrix.matrix import svd


class AdjSVD():
    def __init__(self, adj, k):
        self.adj = adj.asfptype()
        self.k = k
        self.embedding = self.calculate_embedding()

    def calculate_embedding(self):
        u, e, v = svd(self.adj, self.k)
        return u

    def get_embedding(self):
        return self.embedding

    def evaluate(self):
        ...

if __name__ == '__main__':
    g = pkl.load(open('../../../data/BlogCatalog3/preprocessed/graph.pkl', 'rb'))
    adj = g['adj']

    model = AdjSVD(adj, k=64)
    embedding = model.get_embedding()
    print(embedding)